package databaseConnect;

import java.util.Vector;

public class HostConfigurationRequestProcessor {
	//Methods
	public static int getLastRowIDFromHostDescriptionTable(){
		Vector<Vector<String>> temp = AccessConnect.executeSelect("SELECT MAX(ID)FROM HostDescription");
		try {
			if (temp != null){
				return Integer.parseInt(temp.firstElement().firstElement());	
			}
			return -1;
		} catch (NumberFormatException e) {
			return -1;
		}
	}
	
	
	public static Vector<Vector<String>> getHostParameterRows (){
		Vector<String> temp = AccessConnect.getColumnNamesForSelect("SELECT * FROM HostDescription");
		Vector<Vector<String>> pivot = new Vector<Vector<String>>();
		for (int i = 0 ; i < temp.size(); i++ ){
			Vector<String> temptemp = new Vector<String>();
			temptemp.add(temp.get(i));
			if (temp.get(i).equals("ID")){
			temptemp.add("" + (getLastRowIDFromHostDescriptionTable() + 1));	
			} else {
			temptemp.add("0");
			}
			pivot.add(temptemp);
		}
		return pivot;
	}
	
	public static Vector<Vector<String>> getHostServiceRows (int hostId){
		return AccessConnect.executeSelect("SELECT Service FROM HostServices WHERE HostID=" + hostId);
	}
}
